import { defHttp } from '@/utils/http/axios';
import { DB, Table, Column, GetTableListParams, GetColumnListParams } from './model/datasource';
import { BasicFetchResult } from '@/api/model/baseModel'
import { ErrorMessageMode } from '#/axios';

export function getDBList(mode: ErrorMessageMode = 'message') {
  return defHttp.get<BasicFetchResult<DB>>(
    {
      url: '/datacenter/datasource/dbs',
    },
    {
      errorMessageMode: mode
    }
  );
}

export function getTableList(params: GetTableListParams, mode: ErrorMessageMode = 'message') {
  return defHttp.get<BasicFetchResult<Table>>(
    {
      url: '/datacenter/datasource/tables',
      params,
    },
    {
      errorMessageMode: mode
    }
  );
}

export function getColumnList(params: GetColumnListParams, mode: ErrorMessageMode = 'message') {
  return defHttp.get<BasicFetchResult<Column>>(
    {
      url: '/datacenter/datasource/columns',
      params,
    },
    {
      errorMessageMode: mode
    }
  );
}